#ifndef _UTILS_4C653818_FEC9_49C8_8795_6EFF3D03B24A_
#define _UTILS_4C653818_FEC9_49C8_8795_6EFF3D03B24A_
#include <windows.h>
#include "base/file_path.h"

extern const wchar_t kMessageWindowClass[];

void* SetWindowUserData(HWND hwnd, void* user_data);
void* GetWindowUserData(HWND hwnd);

template <typename T>
inline bool compare_array(const T* left, const T* right, size_t len) {
	for (size_t index = 0; index < len; ++index) {
		if (*(left + index) != *(right + index)) {
			return false;
		}
	}
	return true;
}

// 采用模板元的方式实现compare_array功能
// 其编译阶段就已经生成类似如下语句(为显示方便,函数嵌套显示略去): 
// (*left == *right) && (*(left + 1) == *(right + 1)) && ... && (*(left + N - 1) == *(right + N - 1))
// 从而避免compare_array的循环语句
template <typename T, size_t N>
struct inner_compare {
  bool operator()(const T* left, const T* right) {
    return (*left == *right) && inner_compare<T, N - 1>()(left + 1, right + 1);
  }
};

template <typename T>
struct inner_compare<T, 1> {
  bool operator()(const T* left, const T* right) {
    return *left == *right;
  }
};

template <typename T, size_t N>
inline bool make_inner_compare(const T (&a)[N], const T* b) {
  return inner_compare<T, N>()(a, b);
}

bool FileExists(const FilePath& path);

#define IPC_MESSAGE_OBJ_HANDLER(msg_class, obj, member_func) \
  IPC_MESSAGE_FORWARD(msg_class, obj, _IpcMessageHandlerClass::member_func)

#endif//_UTILS_4C653818_FEC9_49C8_8795_6EFF3D03B24A_
